import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

//解决replace重复点击报错问题
const originalReplace = Router.prototype.replace;
Router.prototype.replace = function replace(location) {
  return originalReplace.call(this, location).catch((err) => err);
};

//解决push重复点击报错问题
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) { 
  return originalPush.call(this, location).catch((err) => err);
};

export default new Router({
    routes:[
        {
            path:'/',
            redirect:'/login',
        },
        {
            path:'/login',
            name:'login',
            component:()=>import('@/views/login.vue')
        },
        {
            path:'/register',
            name:'register',
            component:()=>import('@/views/register.vue')
        },
        {
            path:'/home',
            name:'home',
            component:()=>import('@/views/home/index.vue'),
            redirect:"/home/user",
            children:[
                {
                    path:"/home/user",name:"user",component:()=>import("@/views/home/child/users")
                },
                {
                    path:"/home/rights",name:"rights",component:()=>import("@/views/home/child/rights")
                },
                {
                    path:"/home/resource",name:"resource",component:()=>import("@/views/home/child/resource")
                },
                {
                    path:"/home/finance",name:"finance",component:()=>import("@/views/home/child/finance")
                },
            ]
        },
        {
            path:'*',
            name:'404',
            component:()=>import('@/views/notFound.vue')
        },
        
    ]
})

